\subsection{Application Monitoring Layer} 
\label{sec:ApplicationMonitoringLayer}

Each activity affecting the application state (instance creation, field update or method call) is monitored using an aspect. When an instance is created, if its class type is part of the \textsf{Declaration}s within the \SAR configuration, the aspect \texttt{RelevantClassObserver} detects the object using a pointcut of the form \texttt{execution(*.new (..))}, and passes it to the representation layer.

Field value update detection is more sophisticated: pointcuts of the form \texttt{set(* *)} only work for Java primitive types (strings, integers, booleans and so on). To monitor changes within the other supported data structures (like \texttt{ArrayList}s), a specific pointcut is defined to detect the execution of all methods altering the contents of the  data structure (for example, \texttt{ArrayList.clear} or \texttt{ArrayList.set}). The pointcut below is specifically defined for the class \texttt{ArrayList}. Currently, our implementation supports fields whose type is a primitive type and unidimensional structures (\texttt{Vector}s, \texttt{HashSet}s and \texttt{ArrayList}). It is however straightforward to support more data structures.

Finally, method calls are intercepted using a pointcut of the form \textsf{(call(public * *(..)))}. This aspect is of type \textit{around}, i.e. the call is not executed until the aspect code is executed. This allows verification of the policy state at the \textsc{Pdp} before allowing the execution of the method.

\noindent
\begin{minipage}{0.95\columnwidth}
\center
	\begin{boxedminipage}[t]{0.7\textwidth}
\includegraphics[scale=0.5]{aspectAttributes.pdf} 
	\end{boxedminipage}
\end{minipage}

